package czk.jvm.lecture.gc;

/**
 * 配置虚拟机参数
 * -verbose:gc 详细的gc
 * -Xmx20m 设置对打堆内存为20m
 * -Xms20m 设置最小堆内存为20m
 * -Xmn10m 设置年轻代为10m
 * -XX:+PrintGCDetails 打印垃圾会搜信息
 * -XX:SurvivorRatio=8 Eden和suivivor区域比例为8:1
 */
public class MyTest1 {
    public static void main(String[] args) {
        int size=1024*1024;//设置为size为1m
        byte[] byte1=new byte[2*size];
        byte[] byte2=new byte[2*size];
        byte[] byte3=new byte[3*size];
        /**
         * 运行信息
         * [GC (Allocation Failure)  内存分配失败
         * [PSYoungGen: 7118K->712K(9216K)]  新生代空间由；垃圾回收前的7118k经过回收后变成712k 新生代所占内存为9m 1m的suivivor空闲
         * 7118K->5840K(19456K) 堆空间所占内存 由回收前的7118k变为5840K 堆空间所占内存为19456k=19m
         * , 0.0043210 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
         * [Full GC (Ergonomics) [PSYoungGen: 712K->0K(9216K)] [ParOldGen: 5128K->5713K(10240K)] 5840K->5713K(19456K), [Metaspace: 3103K->3103K(1056768K)], 0.0058223 secs] [Times: user=0.02 sys=0.01, real=0.01 secs]
         * hello
         * Heap
         * PSYoungGen(PS：parnew serial 收集器)      total 9216K, used 3394K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
         *   eden space 8192K, 41% used [0x00000000ff600000,0x00000000ff950938,0x00000000ffe00000)
         *   from space 1024K, 0% used [0x00000000ffe00000,0x00000000ffe00000,0x00000000fff00000)
         *   to   space 1024K, 0% used [0x00000000fff00000,0x00000000fff00000,0x0000000100000000)
         *  ParOldGen       total 10240K, used 5713K
         *  老年代
         *
         *  [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
         *   object space 10240K, 55% used [0x00000000fec00000,0x00000000ff194698,0x00000000ff600000)
         *  Metaspace       used 3134K, capacity 4496K, committed 4864K, reserved 1056768K
         *   class space    used 343K, capacity 388K, committed 512K, reserved 1048576K
         */
        System.out.println("hello");
    }
}
